package com.example.composedemo

import android.os.Bundle
import android.widget.Button
import android.widget.EditText
import androidx.activity.ComponentActivity
import com.example.generator.R
import com.github.hook.Hsga464ga

class GeneratorActivity : ComponentActivity() {

    val pub: String =
        "MDwwDQYJKoZIhvcNAQEBBQADKwAwKAIhAJb5DiWtgufI8vwKuU+3u/R27g2PGTYZQqibcKpN4bhdAgMBAAE"

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        setContentView(R.layout.activity_generator)

        val etTime = findViewById<EditText>(R.id.et_time)
        val etVersion = findViewById<EditText>(R.id.et_version)
        val bt = findViewById<Button>(R.id.btn_generate)
        val refresh = findViewById<Button>(R.id.btn_refresh)
        val etKey = findViewById<EditText>(R.id.et_key)

        etTime.setText("${System.currentTimeMillis() + 30 * 60 * 1000}")
        etVersion.setText("552")
        refresh.setOnClickListener {
            etTime.setText("${System.currentTimeMillis() + 30 * 60 * 1000}")
        }
        bt.setOnClickListener {
            val time = etTime.text.toString().toLong()
            val version = etVersion.text.toString().toLong()
            val origin = buildString {
                append(time.toString(16))
                append("-")
                append(version.toString(16))
            }
            etKey.setText(Hsga464ga.e64a8sdg(origin, pub))
        }
    }
}